/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2023-08-18
 * Time: 16:14
 */
public class Test {
    public int romanToInt(String s) {
        int num=0;
        int i;
        for(i=0;i<s.length();i++){
            if(s.charAt(i)=='I'){
                if(i+1<s.length()&&s.charAt(i+1)=='V'){
                    num+=4;
                    i++;
                }else if(i+1<s.length()&&s.charAt(i+1)=='X'){
                    num+=9;
                    i++;
                }else{
                    num+=1;
                }
            }else if(s.charAt(i)=='V'){
                num+=5;
            }else if(s.charAt(i)=='X'){
                if(i+1<s.length()&&s.charAt(i+1)=='L'){
                    num+=40;
                    i++;
                }else if(i+1<s.length()&&s.charAt(i+1)=='C'){
                    num+=90;
                    i++;
                }else{
                    num+=10;
                }
            }else if(s.charAt(i)=='L'){
                num+=50;
            }else if(s.charAt(i)=='C'){
                if(i+1<s.length()&&s.charAt(i+1)=='D'){
                    num+=400;
                    i++;
                }else if(i+1<s.length()&&s.charAt(i+1)=='M'){
                    num+=900;
                    i++;
                }else{
                    num+=100;
                }
            }else if(s.charAt(i)=='D'){
                num += 500;
            }else if(s.charAt(i)=='M'){
                num += 1000;
            }
        }
        return num;
    }
    public static int removeElement(int[] nums, int val) {
        int len = 0;
        int left = 0;
        for (int i = 0; i < nums.length; i++) {
            if(nums[i] != val){
                nums[left] = nums[i];
                len++;
                left++;
            }
        }
        return len;

    }
    public static void main(String[] args) {
        int[] arry = {1,2,3,4,5,2,4};
        int ret = removeElement(arry,2);
        System.out.println(ret);
    }
}
